<?

//声明启用session
session_start();

//鉴权
include_once '../controller/script/check_session.php';


//载入根目录config设定
include_once($_SERVER['DOCUMENT_ROOT']."/config.php");

$user_id = $_SESSION['mid'];
$goods_id = $_REQUEST['nid'];

if($_REQUEST['act'] == 'ajax'){


    $c_goods=select_one_line_all_items($table_prefix."product_collection","user_id=".$user_id.' and  goods_id ='.$goods_id);

    if(!$c_goods){
        $sql = insert_data($table_prefix."product_collection",['ai_user_id'=>$user_id,'ai_goods_id'=>$goods_id]);

        $result = mysql_query($sql);

        if($result){
            echo 1;
        }
        else{
            echo 2;
        }
    }
    else{
        echo 0;
    }

    exit;
}




//根据页面信息，组装查找语句
include_once("script/set_page.php");


//根据页面数量信息，筛选信息，创造url，供页码使用
include_once("script/set_url.php");

$user_collection_nid =select_lines_all_items($table_prefix."product_collection","date desc",
    "user_id=".$user_id);

$goods_ids = transform_2darray_in_1darray_number_as_key($user_collection_nid,'goods_id');

if($goods_ids){
    $goods_id = implode(',',$goods_ids);

    $_asset_list=select_lines_all_items($table_prefix."asset_data","listorder desc,title asc,nid desc",
        'nid in ('.$goods_id.')',"$_data_start,$_quantity_per_page");

}


?>